package com.shunhe.storage.ui.system;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.widget.AppCompatEditText;

import com.ruitu.arad.base.BaseActivity;
import com.ruitu.arad.util.ToastUtils;
import com.ruitu.router_module.util.ViewUtil;
import com.shunhe.storage.R;

public class LoginActivity extends BaseActivity {
    private AppCompatEditText et_name, et_pwd;// 用户名,密码
    private TextView tv_login;// 登录

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_login;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        et_name = findViewById(R.id.et_name);
        et_pwd = findViewById(R.id.et_pwd);
        tv_login = findViewById(R.id.tv_login);

        setOnClickListener(tv_login);

        setHeadTitle("登录");
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (v == tv_login) {
            if (ViewUtil.isTvEmpty(et_name)) {
                ToastUtils.showShort("请输入用户名");
                return;
            }
            if (ViewUtil.isTvEmpty(et_pwd)) {
                ToastUtils.showShort("请输入密码");
                return;
            }
            final String name = ViewUtil.getTxt(et_name);
            final String pwd = ViewUtil.getTxt(et_pwd);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(260);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ToastUtils.showShort(name + "登录成功");
                            finish();
                        }
                    });
                }
            }).start();
        }
    }
}